package com.example.a2032.repositories;

import android.content.Context;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;

import com.hyphenate.chat.EMChatManager;
import com.hyphenate.chat.EMChatRoomManager;
import com.hyphenate.chat.EMClient;
import com.hyphenate.chat.EMContactManager;
import com.hyphenate.chat.EMGroupManager;
import com.hyphenate.chat.EMPushManager;

import com.hyphenate.easeui.manager.EaseThreadManager;

public class BaseEMRepository {

    /**
     * return a new liveData
     * @param item
     * @param <T>
     * @return
     */
    public <T> LiveData<T> createLiveData(T item) {
        return new MutableLiveData<>(item);
    }

    /**
     * login before
     * @return
     */
    public boolean isLoggedIn() {
        return EMClient.getInstance().isLoggedInBefore();
    }

    /**
     * 获取本地标记，是否自动登录
     * @return
     */
    public boolean isAutoLogin() {
        return true;
    }

    /**
     * 获取当前用户
     * @return
     */
    public String getCurrentUser() {
        return "DemoHelper.getInstance().getCurrentUser()";
    }

    /**
     * EMChatManager
     * @return
     */
    public EMChatManager getChatManager() {
        return null;
    }

    /**
     * EMContactManager
     * @return
     */
    public EMContactManager getContactManager() {
        return EMClient.getInstance().contactManager();
    }

    /**
     * EMGroupManager
     * @return
     */
    public EMGroupManager getGroupManager() {
        return null;
    }

    /**
     * EMChatRoomManager
     * @return
     */
    public EMChatRoomManager getChatRoomManager() {
        return null;
    }


    /**
     * EMPushManager
     * @return
     */
    public EMPushManager getPushManager() {
        return null;
    }

    /**
     * init room
     */
    public void initDb() {
        //DemoDbHelper.getInstance(DemoApplication.getInstance()).initDb(getCurrentUser());
    }



    /**
     * 在主线程执行
     * @param runnable
     */
    public void runOnMainThread(Runnable runnable) {
        EaseThreadManager.getInstance().runOnMainThread(runnable);
    }

    /**
     * 在异步线程
     * @param runnable
     */
    public void runOnIOThread(Runnable runnable) {
        EaseThreadManager.getInstance().runOnIOThread(runnable);
    }


}
